<template>
	<view class="container">
		<top-back-navbar position="fixed" title="钱包-提现" :background="pageColor"
			:color="fontColor"></top-back-navbar>
	
		<view class="header u-f-ajc u-f-column relative" :class="[(pageShowType == 2?'cz-box-gf':'')]" >
			<view class="f-w-700">可用资金</view>
			<view class="f-w-700" style="font-size: 50rpx;margin-bottom: 10rpx;">￥{{credit}}</view>
			
			<view class="absolute abso_box" @click="$u.route(`/pages/member/acommsion/projcommision/details?type=jb`)">提现记录</view>
			
			<view class="bottom">
				<input type="text" class="num" v-model="money" placeholder="请输入提现金额" value="" />
				<view class="button" @click="tixian">
					立即提现
				</view>
			</view>
		</view>
		<view class="" v-if="bank_obj_err!= 0">
			<view class="">
				银行信息
			</view>
			<view class="" style="color: red;">
				{{bank_obj.message}}
			</view>
		
		</view>
		<view class="" v-else>
			<view class="">
				银行信息
			</view>
			<view class="">
				开户名称:&nbsp;&nbsp;&nbsp;{{bank_obj.accountName}}
			</view>
			<view class="">
				开户账号:&nbsp;&nbsp;&nbsp;{{bank_obj.bankCardNo}}
			</view>
			<view class="">
				开户银行:&nbsp;&nbsp;&nbsp;{{bank_obj.bankname}}
			</view>
			<view class="">
				开户网点:&nbsp;&nbsp;&nbsp;{{bank_obj.bankbranch}}
			</view>
		</view>
		
		<!-- <view class="radio_list">
			<view class="radio_item u-f-ac u-f-jsb" @click="value='yhk'">
				<view class="u-f-ac">
					<image src="/static/images/mine/yhk.jpg" mode="widthFix" class="item_image"></image>
					<view class="f-w-700">提现到银行卡</view>
				</view>
				<view>
					<radio value="yhk" :color="pageColor" :checked='value == "yhk"' /></radio>
				</view>
			</view>
		</view>-->


	

	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageColor:'#001b4d',
				fontColor:'#ffffff',
				id: '',
				num: '',
				type: '',
				pageShowType: 1,
				value: 'yhk',
				delta: '',
				userInfo: {},
				requestQueyr:'',
				credit:'0.00',
				money:'',
				openid:'',
				bank_obj:{
					accountName:'',
					bankCardNo:'',
					bankname:'',
					bankbranch:'',
				},
				bank_obj_err:0
			}
		},
		onShow: function() {
			// uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
						this.get_bank_value()
				},
				fail: () => {
					uni.navigateTo({
						url: '../index/index'
					});
				}
			});
		},
		onLoad(e) {
			this.pageShowType = e.type ? e.type : 1;
			if(this.pageShowType==2){
				this.requestQueyr='&type=gf';//国风的蛋进入
				this.pageColor='#BA1B21';
				this.fontColor='#000000'
			}else if(this.pageShowType==3){
				this.requestQueyr='&type=fly_egg';//会飞的蛋进入
				this.pageColor='#224f91';
				this.fontColor='#ffffff'
			}
			else if(this.pageShowType==5){
				this.requestQueyr='&type=life';//海贝的蛋进入
				this.pageColor='#224f91';
				this.fontColor='#ffffff'
			}
			else if(this.pageShowType==6){
				this.requestQueyr='&type=za';//沉香的蛋进入
				this.pageColor='#003563';
				this.fontColor='#ffffff'
			}
			this.getMember()
		
		},

		methods: {
			async getMember() {
				let {
					data
				} = await this.$myRequest({
					url: `/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1${this.requestQueyr}`,
					data: {
						openid: uni.getStorageSync('openid')
					}
				})
				console.log(data)
				this.credit=this.lodash.isNumber(Number(data.credit2))?data.credit2:'0.00';
			},
			get_bank_value(){
				var _this=this
				uni.request({
					url: `${this.$BASE_URL}/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.index.show_zishanghu_info&app=1`,
					method: 'POST',
					data: {
						'openid': this.openid,
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						
						var data = res.data
						console.log(data);
						_this.bank_obj_err=data.error
						if(data.error==0){
							_this.bank_obj=data.info
						}else{
							_this.bank_obj.message=data.message
						
						}
						console.log(_this.bank_obj);
					},
					fail: () => {},
					complete: () => {}
				})
			},
			tixian_sure(){
				var _this=this
				uni.request({
					url: `${this.$BASE_URL}/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.withdraw.submit&app=1${this.requestQueyr}`,
					method: 'POST',
					data: {
						'openid': this.openid,
						'money': this.money,
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						
						if (res.data.status == 0) {
							uni.showToast({
								icon:'none',
								title: res.data.result.message,
							
							})
							return
						}
						if (res.data.status == 1) {
							uni.showToast({
								icon:'none',
								title: res.data.result.message,
								
							})
							_this.getMember()
							return
							
						}
					
						uni.hideLoading()
					},
					fail: () => {},
					complete: () => {}
				})
			},
			tixian() {
				var _this=this
				if(this.money==''){ 
					uni.showToast({
						icon:'none',
						title:'请输入提现金额'
					})
					return
				}
				uni.showModal({
					icon:'none',
					title:`确认提现${this.money}吗`,
					success(res) {
						if(res.confirm){
							_this.tixian_sure()
						}
					}
				})
			

			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #f2f5fa;
		box-sizing: border-box;
	}

	.container {
		padding: 30rpx;
		height: 100%;
	}

	.big_title {
		font-size: 32rpx;
		color: #1e1310;
		font-weight: 600;
	}

	.header {
		background-color: #fff;
		width: 100%;
		// height: 200rpx;
		box-sizing: border-box;
		border-radius: 20rpx;
		box-shadow: 0px 2px 8px 3px rgba(235,235,235,0.4);;
		margin: 20rpx 0 30rpx;
		color: #001B4D;
		padding: 20px 0;
	}

	.cz-box-gf {
		background: transparent url(/static/images/home/gy_qb_bg.png) center no-repeat;
		background-size: 100% 100%;
	}

	.abso_box {
		right: 20rpx;
		top: 20rpx;
		border-radius: 50px;
		background-color: #fff;
		padding: 5rpx 20rpx;
		border:1px solid #D6D6D6;
		color:#D6D6D6;
	}

	.radio_list {
		.radio_item {
			background-color: #FFFFFF;
			width: 100%;
			height: 110rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			box-shadow: 0px 2px 8px 3px rgba(235,235,235,0.4);;
			padding: 0 50rpx;

			image {
				width: 100rpx;
				margin-right: 20rpx;
			}

			view {
				font-size: 30rpx;
			}

			radio {
				transform: scale(0.8, 0.8);
			}
		}
	}

	.footer {
		position: fixed;
		bottom: 50rpx;
		left: 0;
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		z-index: 999;
	}

	.footer button {
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 50rpx;
		background: #32539b;
	}

	.footer button.button-hover {
		background: #dc4d4d;
	}

	.btn-gf {
		background-color: #dc4d4d!important;
	}
	.bottom{
		width: 100%;

		display:flex;
		justify-content: space-around;
		align-items: center;
		.num{
			text-align: center;
			border-bottom: 1px solid #d6d6d6;
		}
		.button{
			width: 30%;
			height: 30px;
			background-color:#0751AA;
			border-radius: 50px;
			color: #fff;
			text-align: center;
			line-height: 30px;
		}
	}
</style>
